import http from '../../../util/http.js';


//订单主表Ajax前缀
const ArticleTypePrefix = "/article/type";


export function typeList() {
    let url = `${ArticleTypePrefix}/tree/list`;
    return new Promise((resolve, reject) => {
        http.get(url).then(response => {
            resolve(response)
        });
    });
}


//新增图文分类
export function typeAdd(data) {
    let url = `${ArticleTypePrefix}/add`;
    return new Promise((resolve, reject) => {
        http.post(url, data).then(response => {
            resolve(response)
        });
    });
}


//根据图文分类ID修改图文分类
export function typeUpdate(id, data) {
    let url = `${ArticleTypePrefix}/update/${id}`;
    return new Promise((resolve, reject) => {
        http.put(url, data).then(response => {
            resolve(response)
        });
    });
}


//删除图文分类
export function typeDelete(id) {
    let url = `${ArticleTypePrefix}/delete/${id}`;
    return new Promise((resolve, reject) => {
        http.delete(url).then(response => {
            resolve(response)
        });
    });
}





const NewsPrefix = "/article/news";

export function newsFind(id) {
    let url = `${NewsPrefix}/find/${id}`;
    return new Promise((resolve, reject) => {
        http.get(url).then(response => {
            resolve(response)
        });
    });
}




export function newsList(pagination, param) {
    let url = `${NewsPrefix}/list/${pagination.pageSize}/${pagination.current}`;
    return new Promise((resolve, reject) => {
        http.get(url, param).then(response => {
            resolve(response)
        });
    });
}


//新增图文分类
export function newsAdd(data) {
    let url = `${NewsPrefix}/add`;
    return new Promise((resolve, reject) => {
        http.post(url, data).then(response => {
            resolve(response)
        });
    });
}


//根据图文分类ID修改图文分类
export function newsUpdate(id, data) {
    let url = `${NewsPrefix}/update/${id}`;
    return new Promise((resolve, reject) => {
        http.put(url, data).then(response => {
            resolve(response)
        });
    });
}


//删除图文分类
export function newsDelete(id) {
    let url = `${NewsPrefix}/delete/${id}`;
    return new Promise((resolve, reject) => {
        http.delete(url).then(response => {
            resolve(response)
        });
    });
}






const MessagePrefix = "/article/message";

export function messageFind(id) {
    let url = `${MessagePrefix}/find/${id}`;
    return new Promise((resolve, reject) => {
        http.get(url).then(response => {
            resolve(response)
        });
    });
}




export function messageList(pagination, param) {
    let url = `${MessagePrefix}/list/${pagination.pageSize}/${pagination.current}`;
    return new Promise((resolve, reject) => {
        http.get(url, param).then(response => {
            resolve(response)
        });
    });
}




export function messageReply(id, data) {
    let url = `${MessagePrefix}/reply/${id}`;
    return new Promise((resolve, reject) => {
        http.post(url, data).then(response => {
            resolve(response)
        });
    });

}